package wicresoft.controller.common;


import com.baidu.unbiz.fluentvalidator.ComplexResult;
import com.baidu.unbiz.fluentvalidator.ValidationError;

/**
 * 功能:
 * 作者: 洪世成
 * 日期: 2017/9/10
 * 版权所有: admin
 */
public class CommonResult {
    public static String ZJ000_M = "系统异常。";
    public static String ZJ001_M = "成功。";
    public static String ZJ005_M = "字段异常。";

    public static String ZJ000 = "zj000";
    public static String ZJ001 = "zj001";
    public static String ZJ005 = "zj005";



    private String code;
    private String message;
    private Object data;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static  CommonResult  newCommonResult() {
        CommonResult commonResult = new CommonResult();
        return commonResult;
    }

    public void addMessage(ComplexResult complexResult) {
        for (ValidationError error : complexResult.getErrors()) {
            setMessage(error.getErrorMsg());
        }


    }
}
